<?php
// +----------------------------------------------------------------------
// | xiongrui [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.xiongrui.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.xiongrui.cn>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\common\controller\Admin;
use app\common\model\WxUser;
use app\common\exception\Skip;
use app\admin\validate\MustBePostivelnt;
use app\admin\model\ReturnBalanceLog;
use think\Request;

class Order extends Admin {
  protected $Order;
  protected $OrderShoplist;
  protected $Comment;
  public function _initialize() {
		parent::_initialize();
    $this->Order = model('Order');
    $this->OrderShoplist = model('OrderShoplist');
    $this->Comment = model('Comment');
	}

  public function index() {

    $map['buystatus'] = array('gt','-1');
    $map['company_id'] = 0;
    if(input('out_trade_no')){
      $map['out_trade_no'] = array('like', '%'.input('out_trade_no').'%');
    }
    if(input('wxname')){
      $map['nick_name|user_name|tel'] = array('like', '%'.input('wxname').'%');
    }
    if(input('rebate_code')){
      $map['rebate_code'] = input('rebate_code');
    }
    if(input('start') && input('end')){
      $map['create_time'] = array('between time', [input('start'), input('end')]);
      $map['buystatus'] = array('gt','0');
    }
    if(input('pay')){
      $map['pay'] = input('pay');
    }

    if(input('index_type') != ''){
      $map['index_type'] = input('index_type');
    }

    if(input('ztz')){
        $map['zt_address'] =  ['like','%'.input('ztz').'%'];
    }
    if(input('psy')){
        $map['allot_person'] =  input('psy');
    }

    //print_r($Think);exit();
    if(getGroupId()==6){
      $map['rebate_code'] = session('user_auth.uid');
      $map['index_type'] = ['in', '1,2'];

      $this->assign('shopsau', '1');
    }
    $request = Request::instance();
    $param=$request->param();
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->whereTime('create_time','>',  date("Y-m-d",strtotime("-1 month")))->where($map)->order('id desc')->paginate(10,false,array('query' => $param));
    $sum = $this->Order->where($map)->sum('total');
    $shopsSum = $this->Order->where($map)->sum('shop_price');
    $balanceSum = $this->Order->where($map)->sum('balance');
    $coupoSum = $this->Order->where($map)->sum('coupon_price');
    $freightSum = $this->Order->where($map)->sum('freight');
    $packPriceSum = $this->Order->where($map)->sum('pack_price');
    $payPriceSum = $this->Order->where($map)->sum('pay_price');



    //自提站列表
    $ztzlist = db('DeliveryArayacak')->select();
    $this->assign('ztzlist', $ztzlist);

    //配送员列表
    $psylist =  db('delivery_person')->select();
    $this->assign('psylist', $psylist);


    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->assign('sum', $sum);
		$this->assign('shopsSum', $shopsSum);
		$this->assign('balanceCoupoSum', $balanceSum+$coupoSum);
		$this->assign('sjzfSum', $sum-$balanceSum);
		$this->assign('freightSum',$freightSum);
		$this->assign('packPriceSum',$packPriceSum);
		$this->assign('payPriceSum',$payPriceSum);
		$this->setMeta('全部订单');
		return $this->fetch();
	}

  public function search() {

      $map['buystatus'] = array('gt','-1');
      $map['company_id'] = 0;
    if(input('out_trade_no')){
      $map['out_trade_no'] = array('like', '%'.input('out_trade_no').'%');
    }
    if(input('wxname')){
      $map['nick_name|user_name|tel'] = array('like', '%'.input('wxname').'%');
    }
    if(input('rebate_code')){
      $map['rebate_code'] = input('rebate_code');
    }
    if(input('start') && input('end')){
      $map['create_time'] = array('between time', [input('start'), input('end')]);
      $map['buystatus'] = array('gt','0');
    }
    if(input('pay')){
      $map['pay'] = input('pay');
    }

    if(input('index_type') != ''){
      $map['index_type'] = input('index_type');
    }

    if(input('ztz')){
        $map['zt_address'] =  ['like','%'.input('ztz').'%'];
    }
    if(input('psy')){
        $map['allot_person'] =  input('psy');
    }

    //print_r($Think);exit();
    if(getGroupId()==6){
      $map['rebate_code'] = session('user_auth.uid');
      $map['index_type'] = ['in', '1,2'];

      $this->assign('shopsau', '1');
    }
    $request = Request::instance();
    $param=$request->param();
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->whereTime('create_time','>',  date("Y-m-d",strtotime("-1 month")))->where($map)->order('id desc')->paginate(10,false,array('query' => $param));
    $sum = $this->Order->where($map)->sum('total');
    $shopsSum = $this->Order->where($map)->sum('shop_price');
    $balanceSum = $this->Order->where($map)->sum('balance');
    $coupoSum = $this->Order->where($map)->sum('coupon_price');
    $freightSum = $this->Order->where($map)->sum('freight');
    $packPriceSum = $this->Order->where($map)->sum('pack_price');
    $payPriceSum = $this->Order->where($map)->sum('pay_price');



    //自提站列表
    $ztzlist = db('DeliveryArayacak')->select();
    $this->assign('ztzlist', $ztzlist);

    //配送员列表
    $psylist =  db('delivery_person')->select();
    $this->assign('psylist', $psylist);


    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->assign('sum', $sum);
		$this->assign('shopsSum', $shopsSum);
		$this->assign('balanceCoupoSum', $balanceSum+$coupoSum);
		$this->assign('sjzfSum', $sum-$balanceSum);
		$this->assign('freightSum',$freightSum);
		$this->assign('packPriceSum',$packPriceSum);
		$this->assign('payPriceSum',$payPriceSum);
		$this->setMeta('全部订单');
		return $this->fetch();
	}




  //未支付订单
  public function notpay() {

    $map  = array('buystatus' => array('eq', 0));
    $map['company_id'] = 0;
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->where($map)->order('id desc')->paginate(10);

    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->setMeta('未支付订单');
		return $this->fetch();
	}
  //待发货订单
  public function waiting() {

    $map  = array('buystatus' => array('eq', 1));
        $map['company_id'] = 0;
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->where($map)->order('id desc')->paginate(10);

    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->setMeta('待发货订单');
		return $this->fetch();
	}
  //待配送订单
  public function waiting_delivery() {

    $map  = array('buystatus' => array('eq', 2));
      $map['company_id'] = 0;
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->where($map)->order('id desc')->paginate(10);

    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->setMeta('待配送订单');
		return $this->fetch();
	}
  //待签收订单
  public function waiting_sign() {

    $map  = array('buystatus' => array('eq', 3));
      $map['company_id'] = 0;
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->where($map)->order('id desc')->paginate(10);

    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->setMeta('待签收订单');
		return $this->fetch();
	}
  //已完成订单
  public function complete() {
    $map['company_id'] = 0;
    if(input('out_trade_no')){
      $map['out_trade_no'] = array('like', '%'.input('out_trade_no').'%');
    }
    if(input('wxname')){
      $map['nick_name'] = array('like', '%'.input('wxname').'%');
    }
    if(input('rebate_code')){
      $map['rebate_code'] = input('rebate_code');
    }
    if(input('pay')){
      $map['pay'] = input('pay');
    }
    $map['buystatus']  =  array('eq', 4);
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->where($map)->order('id desc')->paginate(10);

    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->setMeta('待发货订单');
		return $this->fetch();
	}
  //退款订单
  public function refund() {

    $map  = array('buystatus' => array('eq', 5));
      $map['company_id'] = 0;
		$count = $this->Order->where($map)->order('id desc')->count();
    $list = $this->Order->where($map)->order('id desc')->paginate(10);

    Cookie('__forward__',$_SERVER['REQUEST_URI']);
		$this->assign('list', $list);
		$this->assign('count', $count);
		$this->setMeta('待发货订单');
		return $this->fetch();
	}




  public function edit($id) {

		if (!$id) {
			return $this->error("非法操作！");
		}
		if (IS_POST) {
			$result = $this->Order->change();
			return $this->success("编辑成功！", Cookie('__forward__'));
		} else {
      $info = $this->Order->get($id);
      //$shoplist = $this->OrderShoplist->all(['order_id'=>$id]);
      
      $shoplist =  $this->OrderShoplist->alias('b')->join('xsd_goodsrule c','b.rule_id=c.id','LEFT')->where("b.order_id=$id")->field('b.*,c.rule_price as price1,c.rule_price2 as price2')->select();
      

			$this->assign('info',$info);
			$this->assign('shoplist',$shoplist);
			$this->setMeta('订单详情');
			
			
 			//var_dump($shoplist);

			return $this->fetch();
		}
	}

  public function editOrderInfo($id, $remark){
		$return = $this->Order->where('id', $id)->update(['remark'=>$remark]);
		if($return){
			$this->success('操作成功！');
		}else {
			$this->error('修改失败！');
		}
	}

  public function del() {
    $id = $this->getArrayParam('id');
		if (empty($id)) {
			return $this->error("非法操作！");
		}

    $list = $this->Order->where(array('id' => array('IN', $id)))->column('coupon_id,balance,user_id', 'id');

    foreach ($list as $key => $value) {
      if(!empty($value['coupon_id'])){
        db('coupon_list')->where('id',$value['coupon_id'])->update(['status'=>0]);
      }
      if($value['balance'] > 0){
        db('wx_user')->where('id',$value['user_id'])->setInc('balance', $value['balance']);
      }
    }


		$result = $this->Order->where(array('id' => array('IN', $id)))->update(['buystatus'=>-1]);

    if($result){
      return $this->success("删除成功！");
    }else{
      return $this->error("删除失败！");
    }



    // if($result->delete()){
    //     // 删除所有的关联数据
    //     $result->OrderShoplist()->delete();
    //     return $this->success("删除成功！");
    // }else{
    //   	return $this->error("删除失败！");
    // }
	}

  public function acceptOrder($id, $return_price=0){
    if (empty($id)) {
			return $this->error("非法操作！");
		}
    if (IS_POST) {
			$result = $this->Order->get($id);




      $result->accept_status = 1;
      $result->buystatus = 2;
      $result->return_price = $return_price;


      if(false !== $result->save()){
        WxUser::where('id', $result->user_id)->setInc('balance', $return_price);
        //如果返回金额大于 0 发送短信给用户 （短信默认发给会员  会员没有电话的  发给收货人的手机）
        if($return_price > 0){
          $userInfo = WxUser::where('id', $result->user_id)->find();
          //发送给用户
          if(!empty($userInfo['phone'])){
            sendcomSms('SMS_71320253', ['username'=>$userInfo['nickname'], 'money'=>(string)$return_price], (string)$userInfo['phone']);
          }else{
            sendcomSms('SMS_71320253', ['username'=>$userInfo['nickname'], 'money'=>(string)$return_price], (string)$result['tel']);
          }
          //发送给管理员
          sendcomSms('SMS_71320253', ['username'=>$userInfo['nickname'], 'money'=>(string)$return_price], '15885108322');


        }


        $this->success('接单成功！');
      }else{
        $this->error('接单失败！');
      }
		}






      $result = $this->Order->get($id);


      if($result['way'] == 2){
        //发送给自提站长
        $zzphone = db('DeliveryArayacak')->where('name', $result['zt_address'])->value('phone');

        sendcomSms('SMS_124115007', ['user'=>$result['user_name'], 'time'=>$result['create_time'], 'code'=>$result['out_trade_no'], 'total'=> (string)$result['total'].',自提地点：'.$result['zt_address']], (string)$zzphone);


      }
      $result->accept_status = 1;
      $result->buystatus = 2;
      if(false !== $result->save()){
        $this->success('接单成功！');
      }else{
        $this->error('接单失败！');
      }

  }

  public function revokeOrder($id ){
    // if (empty($id)) {
		// 	return $this->error("非法操作！");
		// }
    //
		// 	$result = $this->Order->get($id);
    //   $result->accept_status = 2;
    //   $result->buystatus = 1;
    //   if(false !== $result->save()){
    //     $this->success('撤单成功！');
    //   }else{
    //     $this->error('撤单失败！');
    //   }

  }
  //分配师傅
  public function allot($id, $allot_person){
    if (empty($id)) {
			return $this->error("非法操作！");
		}


		$result = $this->Order->get($id);
    $result->accept_status = 1;
    $result->buystatus = 2;
    $result->allot_person = $allot_person;
    if(false !== $result->save()){
      //读取师傅电话号码并发送短信
      $allotinfo =  model('delivery_person')->where('id', $allot_person)->find();
      sendcomSms('SMS_67770229', ['order'=>(string)$result['out_trade_no'], 'pay'=>config('pay')[$result['pay']], 'time'=>$result['deliverytime'], 'address'=>$result['address'], 'phone'=>(string)$result['tel'], 'name'=>$result['user_name']], (string)$allotinfo['tel']);
      //发送给客户
      //sendcomSms('SMS_67770228', ['sfname'=>$allotinfo['name'], 'phone'=>(string)$allotinfo['tel']], (string)$result['tel']);
      $this->success('分配成功！');
    }else{
      $this->error('分配失败！');
    }
  }

  //发货
  public function shipments($id, $note=1){
    if (empty($id)) {
			return $this->error("非法操作！");
		}
		$result = $this->Order->get($id);
    $result->buystatus = 3;
      if(false !== $result->save()){
        $allotinfo =  model('delivery_person')->where('id', $result->allot_person)->find();
        //发送给客户
        if($note == 1){
            sendcomSms('SMS_67770228', ['sfname'=>$allotinfo['name'], 'phone'=>(string)$allotinfo['tel']], (string)$result['tel']);
        }
          $this->success('发货成功！');
      }else{
          $this->error('发货失败！');
      }
  }

  /**
   * 自提
   * @return [type] [description]
   */
   public function taketheir($id){
     if (empty($id)) {
 			return $this->error("非法操作！");
 		}

    $result = $this->Order->get($id);
    $result->buystatus = 3;

    if(false !== $result->save()){
      $zzphone = db('DeliveryArayacak')->where('name','like','%'.$result['zt_address'].'%')->value('phone');
      $address = $result['zt_address'];
      if($zzphone){
        $address = $result['zt_address'].'(站长电话：'.$zzphone.')';
      }


      //发送给客户
      sendcomSms('SMS_116345001', ['username'=>$result['user_name'], 'address'=>(string)$address], (string)$result['tel']);

      //发送给自提站长

      $this->success('已经发送自提信息给用户');
    }else{
      $this->error('发送短信失败！');
    }

   }


  /**
   * 添加订单快递单号，并发送短信
   * @param  [type] $id         [订单id]
   * @param  [type] $express_no [快递快递信息]
   * @return [type]             [description]
   */
  public function express($id, $express_no){
    //判断参数
    if(empty($id) && empty($express_no)){
      return  $this->error('参数错误');
    }
    $info = $this->Order->get($id);
    $info->buystatus = 3; //订单状态为待签收
    $info->express_no = $express_no;
    if(false !== $info->save()){
      sendcomSms('SMS_121895071', ['username'=>$info['user_name'], 'info'=>(string)$info['express_no']], (string)$info['tel']);
      $this->success('操作成功');
    }else{
      $this->error('操作失败');
    }
  }
  //退款
  public function refundAc($id){
    if (empty($id)) {
			return $this->error("非法操作！");
		}
		$result = $this->Order->get($id);
    $result->buystatus = 5;
    if(false !== $result->save()){
      //退还余额
      db('WxUser')->where('id',$result->user_id)->setInc('balance', $result['total']);
      $this->success('退款成功！');
    }else{
      $this->error('退款失败！');
    }
  }

  //确定签收
  public function sign($id){
    if (empty($id)) {
      return $this->error("非法操作！");
    }
    $result = $this->Order->get($id);
    $result->buystatus = 4;
    $result->sign_time = time();
    if(false !== $result->save()){
      //添加积分
      $total = ceil($result->total);
      db('WxUser')->where('id',$result->user_id)->setInc('integral', $total);
      //插入行为日志
    	//$data['action_id']   = '';
    	$data['user_id']     = $result->user_id;
    	$data['action_ip']   = ip2long(get_client_ip());
    	$data['model']       = 'WxUser';
    	$data['record_id']   = $result->user_id;
    	$data['create_time'] = time();
      $data['remark'] = time_format($data['create_time']).'完成订单'.$result->out_trade_no.'奖励'.$total.'积分';
      db('ActionLog')->insert($data);

    }else{

    }
  }
  public function batchsign(){
    $id = $this->getIds();
    $this->errorInfo($id);
    if(is_array($id)){
      foreach ($id as $key => $value) {
          $this->sign($value);
      }
    }else{
      $this->sign($id);
    }

    $this->success('确定签收成功！');

  }


  //评论列表
  public function comment() {
    $list = $this->Comment->order('id desc')->paginate(10);
    $count = $this->Comment->where($map)->order('id desc')->count();
    $this->assign('list', $list);
    $this->assign('count', $count);
    $this->setMeta('评论列表');
    return $this->fetch();
  }

  //评论列表
  public function delcomment($id=null) {
    if (empty($id)) {
			return $this->error("非法操作！");
		}
		$result = $this->Comment->get($id);
    if($result->delete()){
        return $this->success("删除成功！");
    }else{
      	return $this->error("删除失败！");
    }
  }

  //批量接单
  public function batchaccept(){
    $ids = input('ids/a');
		if (empty($ids)) {
			return $this->error("非法操作！", '');
		}
		$map['id'] = array('IN', $ids);
		$result    = $this->Order->where($map)->update(['accept_status' => 1, 'buystatus'=>2]);
		if ($result) {
			return $this->success('操作成功！');
		} else {
			return $this->error('操作失败！');
		}
  }
  /**
   * 退还金额
   * @return [type] [description]
   */
  public function returnBalance($id, $return_price, $return_dec){
    if(IS_POST){

      if($return_price<=0){
        $this->error('金额必须大于等于0');
      }
      if(!$return_dec){
        $this->error('补退说明不能为空');
      }
      //读取订单信息
      $orderInfo = $this->Order->get($id);
      if(!$orderInfo){
        $this->error('订单不存在');
      }

      //获取用户信息 更新之前的数据
      $userInfo = WxUser::get($orderInfo->user_id);


      //退款到余额  更新后的
      $result = WxUser::where('id', $orderInfo->user_id)->setInc('balance', $return_price);
      if(!$result){
        $this->error('添加余额失败');
      }

      //发送短信给用户
       sendcomSms('SMS_132595028', ['text'=>$return_dec, 'price'=>(string)$return_price.'元'], (string)$orderInfo['tel']);
      // //发送给管理员
       //sendcomSms('SMS_71320253', ['username'=>$userInfo['nickname'], 'money'=>(string)$return_price], '15599136991');

      //记录到return_balance_log日志中
      $resultRbl = ReturnBalanceLog::create([
          'out_trade_no'  =>  $orderInfo['out_trade_no'],
          'user_id'  =>  $orderInfo['user_id'],
          'money'  =>  $return_price,
          'before_balance'  =>  $userInfo['balance'],
          'after_balance'  =>  $userInfo['balance']+$return_price,
          'rdec'  =>  $return_dec,
      ]);
      if(!$resultRbl){
        $this->error('添加日志失败');
      }

      $this->success('补退成功');
    }

  }



  public function returnBalanceIndex(){
    $map = [];
    if(input('out_trade_no')){
      $map['out_trade_no'] = array('like', '%'.input('out_trade_no').'%');
    }
    if(input('wxname')){
      $maps['nickname'] = array('like', '%'.input('wxname').'%');
      $userId = WxUser::where($maps)->value('id');
      if($userId){
          $map['user_id'] =$userId;
      }
    }
    if(input('start') && input('end')){
      $map['create_time'] = array('between time', [input('start'), input('end')]);
    }
      $list = ReturnBalanceLog::where($map)->order('id desc')->paginate(10,false,array('query' => $param));


    $sum = ReturnBalanceLog::where($map)->sum('money');
    $this->assign('list', $list);
    $this->assign('sum', $sum);
    $this->setMeta('补退余额列表');
    return $this->fetch();
  }

  public function createNewsStraightToExl(){
    vendor('phpoffice.phpexcel.Classes.PHPExcel');
    $objPHPExcel = new \PHPExcel();
    $objPHPExcel->getProperties()->setCreator("鲜果屋")
    							 ->setLastModifiedBy("鲜果屋")
    							 ->setTitle("最近5日订单数据")
    							 ->setSubject("最近5日订单数据")
    							 ->setDescription("最近5日订单数据")
    							 ->setKeywords("订单")
    							 ->setCategory("Test result file");
   $objPHPExcel->setActiveSheetIndex(0)
               ->setCellValue('A1', '姓名')
               ->setCellValue('B1', '电话')
               ->setCellValue('C1', '快递单号')
               ->setCellValue('D1', '地址')
               ->setCellValue('E1', '购买产品')
               ->setCellValue('F1', '数量');

    $map['index_type'] = 2; //产地直发
    $date = date('Y-m-d', strtotime('-5 days'));
    $list = model('Order')->whereTime('create_time', '>=', $date)->where($map)->order('id desc')->select();
    if(!$list){
      $this->error('最近5天没有订单数据');
    }


    foreach ($list as $key => $value) {
      $i = $key+2;
      if($value->OrderShoplist){
        $goods_name = '';
        $num = 0;
        foreach ($value->OrderShoplist as $key_s => $value_s) {
            $goods_name .= $value_s['good_name'].',';
            $num += $value_s['num'];
        }
        $goods_name = substr($goods_name, 0, -1);
      }
      $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$i, $value['user_name'])
                  ->setCellValue('B'.$i, $value['tel'])
                  ->setCellValue('C'.$i, $value['express_no'])
                  ->setCellValue('D'.$i, $value['address'])
                  ->setCellValue('E'.$i, $goods_name)
                  ->setCellValue('F'.$i, $num);
    }


   $filename = date('y-m-d h:i:s',time());
   ob_end_clean();//清除缓冲区,避免乱码
   header('Content-Type: application/vnd.ms-excel');
   header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
   header('Cache-Control: max-age=0');
   header('Cache-Control: max-age=1');
   header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
   header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
   header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
   header('Pragma: public'); // HTTP/1.0
   $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
   $objWriter->save('php://output');
  }

  /**
   * 打印页面
   * @return [type] [description]
   */
  public function prints($id = ''){
    if (!$id) {
			return $this->error("非法操作！");
		}
    $info = $this->Order->get($id);
    $shoplist = $this->OrderShoplist->all(['order_id'=>$id]);
		$this->assign('info',$info);
		$this->assign('shoplist',$shoplist);
		$this->setMeta('订单详情');
		return $this->fetch();
  }

  /**
   * 打印页面
   * @return [type] [description]
   */
  public function simpleprints($id = ''){
    if (!$id) {
			return $this->error("非法操作！");
		}
    $info = $this->Order->get($id);
    $shoplist = $this->OrderShoplist->all(['order_id'=>$id]);
		$this->assign('info',$info);
		$this->assign('shoplist',$shoplist);
		$this->setMeta('订单详情');
		return $this->fetch();
  }


}

 ?>
